import { Component, OnInit } from '@angular/core';
import { StatisticsPanelInterface } from 'src/app/model';
import { SiteListDataInterface } from 'src/app/model';
import { EChartsOption } from 'echarts';
import { SiteSummaryService } from 'src/app/services/site-summary.service';
import { Router } from '@angular/router';



@Component({
  selector: 'app-site-summary',
  templateUrl: './site-summary.component.html',
  styleUrls: ['./site-summary.component.scss']
})
export class SiteSummaryComponent implements OnInit {

  statisticsDataArr!: StatisticsPanelInterface[]

  /** 表格数据 */
  TABLE_DATA: Array<SiteListDataInterface> = [
    { status: 1, name: "珠海移动特力集团", lastReportTime: "2022-05-15: 14:21", action: 1, id: 1 },
    { status: 2, name: "珠海移动特力集团", lastReportTime: "2022-05-15: 14:21", action: 1, id: 1 },
    { status: 3, name: "我是新键站点", lastReportTime: "2022-05-15: 14:21", action: 3, id: 1 }
  ]

  displayedColumns: string[] = ['status', 'name', 'lastReportTime', 'action'];

  chartOption: EChartsOption = {
    xAxis: {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
    },
    yAxis: {
      type: 'value',
    },
    series: [
      {
        data: [820, 932, 901, 934, 1290, 1330, 1320],
        type: 'line',
      },
    ],
  };

  constructor(
    private siteSummaryService: SiteSummaryService,
    private router: Router,
  ) { }

  ngOnInit(): void {
    this.getStatisticsPanelData();
    this.getPowerTrend();
    this.getSiteList();
  }

  /**
   * 获取统计面板数据
   */
  async getStatisticsPanelData() {
    // let res: StatisticsPanelInterface[] = await this.siteSummaryService.getStatisticsPanelData();
    let res = [
      {
        key: "基站功率(kw)",
        value: 89.5
      },
      {
        key: "总计电量(kwh)",
        value: 239.5
      },
      {
        key: "累计电费(元)",
        value: 389.5
      },
      {
        key: "节约电费(元)",
        value: 100.5
      },
    ]
    this.statisticsDataArr = res;
  }

  /**
   * 获取功率趋势数据
   */
  getPowerTrend() {

  }

  /**
   * 获取站点列表
   */
  getSiteList() {

  }

  /** 跳转到站点详情页 */
  goDetail(element: SiteListDataInterface) {
    this.router.navigate(['/site-list', element.id])
  }

}
